<?php


namespace app\admin\controller;



use app\model\Retail as RetailModel;

class RetailController extends Base
{
    public function index()
    {
        $create_time = input('post.create_time', '', 'serach_in');
        $res = RetailModel::getRetailList(0);
        $data['data'] = ['item'=>$res];
        return $this->json($data);
    }

    public function detail()
    {
        $id = input('post.id', '', 'serach_in');
        $res = RetailModel::where(['id'=>$id])->find();
        $res['pid_title'] = RetailModel::where(['id'=>$res['pid']])->value('title');
        return $this->json(['data'=>['item'=>$res]]);
    }

    public function update()
    {
        $post = input('post.');
        if(!empty($post['id'])){
            $res = RetailModel::update($post, ['id'=>$post['id']]);
        }else{
            $post['weid'] = weid();
            $res = RetailModel::create($post);
        }
        return $this->json($res);
    }

    public function delete()
    {
        $id = input('post.id', '', 'serach_in');
        $res = RetailModel::update(['status'=>0], ['id'=>$id]);
        return $this->json(['msg'=>'删除成功']);
    }








}